import React, { Component } from "react";
import { withRouter } from "react-router-dom";
import { observer, inject } from "mobx-react";

@withRouter
@inject("page")
@observer
class Com extends Component {
  constructor() {
    super();
    this.state = {
      ajaxCfg: {
        url: "/home/mediareports",
        cfg: {
          page_number: 1,
          page_size: 10,
        },
        headers: {},
      },
    };
  }
  // object.assign 对象合并
  // 调取数据
  getList(ajaxCfg) {
    const { getData } = this.props.page;
    getData(ajaxCfg);
  }
  componentDidMount() {
    this.getList(this.state.ajaxCfg);
  }
  lists() {
    const { data } = this.props.page;
    const lists = data.map((item, index) => {
      return <span key={index}>{item.id}、</span>;
    });
    return lists;
  }
  render() {
    const { data } = this.props.page;
    return (
      <div className="Y_header">{data.length > 0 ? this.lists() : ""}</div>
    );
  }
}
export default Com;
